package com.link.gateway.core.init;

import com.link.gateway.base.dutyinfo.service.DutyInfoService;
import com.link.gateway.base.urlinfo.service.UrlInfoService;
import com.link.gateway.base.visitfrequency.service.VisitFrequencyService;
import com.link.gateway.core.comproperty.YmlProperties;
import com.link.gateway.core.filter.global.LinkTokenGlobalFilter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;


/**
 * @author Guoshan
 * @date 2019-07-23 10:16
 * 启动的时候加载
 */
@Configuration
public class InitBeanProperties implements InitializingBean {
    @Resource
    private YmlProperties ymlProperties;

    @Resource
    private LinkTokenGlobalFilter tokenGlobalFilter;

    @Resource
    private UrlInfoService urlInfoService;

    @Resource
    private DutyInfoService dutyInfoService;

    @Resource
    private VisitFrequencyService visitFrequencyService;

    @Override
    public void afterPropertiesSet() throws Exception {
        //先设置前置的信息
        ymlProperties.afterPropertiesSet();

        //设置默认不拦截地址 guoshan
        tokenGlobalFilter.setUrlSet();

        //加载默认可访问url到redis和全局变量中去 HuangLJ
        urlInfoService.loadUrlToRedis();

        //把所有权限加载进去
//        dutyInfoService.setDutyPermissionToCache();

        //初始化接口访问配置
        visitFrequencyService.loadConfig();
    }

}
